Skip to content

fix(weights): produce copy-pasteable retry command after commit#928

Closed
boskodev790 wants to merge 1 commit into
latent-to:stagingfrom
boskodev790:fix/weights-commit-retry-command-format
Closed

fix(weights): produce copy-pasteable retry command after commit#928
boskodev790 wants to merge 1 commit into
latent-to:stagingfrom
boskodev790:fix/weights-commit-retry-command-format

Conversation

@boskodev790
Copy link
Copy Markdown
Contributor

Summary

  • After btcli weights commit succeeds, _commit_reveal in bittensor_cli/src/commands/weights.py prints a "To manually retry after ... run" message. The printed string is currently unparseable three ways, so copy-pasting it never works:
    • No btcli weights reveal prefix — the line is just flags, with no subcommand.
    • List args are rendered via Python / NumPy repr ([1, 2, 3] for uids/salt, [0.5 0.3 0.2] for the numpy weights array). weights reveal parses these through parse_to_list in cli.py, which splits on commas per the help text (e.g. -u 1,2,3 ...).
    • The flag --reveal-using-salt does not exist on weights reveal; the real flag is --salt.
  • Extract _build_reveal_retry_command as a pure module-level helper and format --uids / --weights / --salt as comma-separated lists. Update the call site in _commit_reveal to use it.
  • Add tests/unit_tests/test_weights_retry_command.py (2 cases) pinning the command shape and asserting regressions against [/] in the output and the legacy --reveal-using-salt flag name.

Related Issues

N/A — code review. Line 183 has been this way since 2024-08-22 (git blame); no open or closed PR addresses the format (search: cli_retry_cmd / reveal-using-salt → 0 matches).

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • Added tests/unit_tests/test_weights_retry_command.py covering the positive shape and the two regressions (numpy repr leakage, --reveal-using-salt).
  • Full existing unit suite passes locally (pytest tests/unit_tests/ — 350 passed).
  • Ran ruff format on both files per CONTRIBUTING.md.

Checklist

  • Code follows project style guidelines (ruff format clean)
  • Self-review completed
  • Changes are documented (helper has a docstring tying it back to parse_to_list)

Copy link
Copy Markdown
Contributor

@thewhaleking thewhaleking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. These aren't even used anymore, hence why the entire weights command is hidden.

@boskodev790 boskodev790 reopened this May 8, 2026
@boskodev790 boskodev790 force-pushed the fix/weights-commit-retry-command-format branch from bc9d11a to 7ee83dd Compare May 11, 2026 18:12
@boskodev790
Copy link
Copy Markdown
Contributor Author

Rebased onto staging (clean conflict resolution in weights.py imports — kept both Iterable and Sequence) and re-signed the commit (SSH-signed, GitHub-verified).

@thewhaleking — fully agree the surface is hidden, but the wt and weight aliases are still wired in bittensor_cli/cli.py (just hidden=True), so any user with automation or a pinned alias who hits _commit_reveal will copy the printed retry command and have it fail to parse (numpy repr for --uids / --weights, non-existent --reveal-using-salt flag, no btcli weights reveal prefix). The fix is +72/-2 with regression tests pinning the format. Happy to close this if the entire alias surface is being removed — let me know either way.

After btcli weights commit, the "To manually retry ... run" message
printed the retry command with three issues that made it unparseable:

- Missing the `btcli weights reveal` prefix, so the user could not run
  the printed line as-is.
- List arguments were rendered via Python/NumPy repr (`[1, 2, 3]` and
  `[0.5 0.3 0.2]`), but the `weights reveal` subcommand parses them
  through `parse_to_list` in cli.py, which splits on commas.
- The flag `--reveal-using-salt` does not exist on `weights reveal`;
  the real flag is `--salt`.

Extract `_build_reveal_retry_command` as a pure helper and format
--uids / --weights / --salt as comma-separated lists, matching the
help text ("e.g. -u 1,2,3 ...") and `parse_to_list`.

Adds `tests/unit_tests/test_weights_retry_command.py` pinning the
command shape, list-arg formatting, and the regression against the
numpy-repr / `--reveal-using-salt` output.

Co-authored-by: Cursor <cursoragent@cursor.com>
@boskodev790 boskodev790 force-pushed the fix/weights-commit-retry-command-format branch from 7ee83dd to 040a16b Compare May 11, 2026 18:32
@boskodev790
Copy link
Copy Markdown
Contributor Author

Follow-up 040a16b8: dropped the import numpy as np from tests/unit_tests/test_weights_retry_command.py so it stops failing Unit-Tests CI (numpy isn't in the project's unit-test dep set — only e2e checks were running last time the test was authored). Replaced np.array([0.5, 0.3, 0.2]) with a tiny _NumpyArrayLikeRepr shim that iterates the same way and whose __str__ produces the exact [0.5 0.3 0.2] shape numpy.ndarray.__str__ does, so the regression assertion still catches the original str(weights) bug (verified locally by reverting the comma-join — both tests fail with --weights [0.5 0.3 0.2] in the output, then pass once restored). All 5 Unit Tests jobs now green; commit remains SSH-signed and GitHub-verified.

@thewhaleking
Copy link
Copy Markdown
Contributor

Rebased onto staging (clean conflict resolution in weights.py imports — kept both Iterable and Sequence) and re-signed the commit (SSH-signed, GitHub-verified).

@thewhaleking — fully agree the surface is hidden, but the wt and weight aliases are still wired in bittensor_cli/cli.py (just hidden=True), so any user with automation or a pinned alias who hits _commit_reveal will copy the printed retry command and have it fail to parse (numpy repr for --uids / --weights, non-existent --reveal-using-salt flag, no btcli weights reveal prefix). The fix is +72/-2 with regression tests pinning the format. Happy to close this if the entire alias surface is being removed — let me know either way.

It doesn't really make sense to add me features to deprecated commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants